<?php

namespace plugin\laoha\app\controller;

use plugin\admin\app\model\User;
use plugin\laoha\app\model\Act;
use support\exception\BusinessException;
use support\Request;
use support\Response;

class ActController extends Crud
{
    protected $noNeedLogin = [];

    public function __construct()
    {
        $this->model = new Act;
        $this->rules = $this->getRules();
    }

    public function index(Request $request)
    {
        $type = $request->input('type', '');
        $id = $request->input('id', '');
        $act = $request->input('act', '');
        $del = $request->input('del', '') ? true : false;
        if (empty($type) || empty($id) || empty($act) || !user_id()) {
            return json_fail('操作失败');
        }
        if ($del) {
            $this->model->del($type, $id, $act);
        } else {
            $this->model->add($type, $id, $act);
        }
        return json_ok('操作成功');
    }
}
